<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=实例属性和方法, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <p ref="hello">{{ msg }}</p>
        <div ref="world">嘿嘿</div>
        <button @click="show">按钮1</button>
        <hr>

        <p ref="wanho">{{name}}</p>
        <button @click="modify">修改name</button>
    </div>

    <script src="js/vue.js"></script>
    <script>
        new Vue({
            // el: '#app', // 挂载
            data: {
                msg: 'hello world',
                name: 'tom'
            },
            methods: {
                show: function(){
                    console.log(1111)

                    console.log(this.$refs.hello)
                },
                modify(){
                    this.name = 'jack'
                    // 此时DOM还没更新，需要时间来更新页面
                    this.$nextTick(function(){
                        console.log(this.$refs.wanho.innerText)
                    })
                }
            }
        }).$mount('#app')

        // console.log(vm)
        // console.log(vm.$el)
        // console.log(vm.$refs.hello)

        // vm.$mount('#app') // 手动挂载
    </script>
</body>
</html>